package company.qianxing_F;

// 全排列
public class Qi2 {

    private int n;

    private int result = 0;

    private int[] digit;

    public int reletive_7(int[] digit) {
        // write code here
        this.n = digit.length;
        this.digit = digit;
        helper("", new int[n]);
        return result;
    }

    private void helper(String s, int[] use) {
        if (s.length() == n) {
            result += Integer.parseInt(s) % 7 == 0 ? 1 : 0;
        } else {
            for (int i = 0; i < n; i++) {
                if (use[i] == 0) {
                    int[] copy = use.clone();
                    copy[i] = 1;
                    helper(s + digit[i], copy);
                }
            }
        }
    }
}
